﻿@model BcdFileListViewModel
@{
    Layout = null;
    ViewBag.Title = "案卷弹出框";
}
<div class="pageContent" layouth="38">
    <form method="post" action="demo/common/ajaxDone.html" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone)" layouth="38">
        <div id="div_file_relation_zTree" style="display: none; margin-left: 10px; margin-top: 10px;">无可关联的案卷信息</div>
        <ul id="file_relation_zTree" class="ztree">
        </ul>
    </form>
</div>
<div class="formBar">
    <ul>
        <li>
            <button type="button" class="btn btn-success btn-sm" onclick="file_relation_zTree_typeSel()">
                选择</button>
        </li>
        <li>
            <button type="button" class="close btn btn-default btn-sm">
                取消</button>
        </li>
    </ul>
</div>
<script type="text/javascript">
    var file_relation_zTree;
    var file_relation_zTree_setting = {
        treeObjId: "file_relation_zTree",
        isSimpleData: true,              //数据是否采用简单 Array 格式，默认false
        treeNodeKey: "id",               //在isSimpleData格式下，当前节点id属性
        treeNodeParentKey: "pId",        //在isSimpleData格式下，当前节点的父节点id属性
        showLine: true,                  //是否显示节点间的连线
        checkable: true,                 //每个节点上是否显示 CheckBox
        checkStyle: "checkbox"   //多选 checkbox   单选 radio
    };
    $(function () {
        $.getJSON(
           "/CompletionMaterials/FileList/FileRelationJson?proId=@(ViewBag.proId)&fId=@(ViewBag.fId)",
           function (data) {
               if (data.length == 0)
                   $("#div_file_relation_zTree").show();
               else {
                   $("#div_file_relation_zTree").hide();
                   file_relation_zTree = $("#file_relation_zTree").zTree(file_relation_zTree_setting, data);
               }
           });
    });
    function file_relation_zTree_typeSel() {
        var flIds = "";
        var nodes = file_relation_zTree.getCheckedNodes(true);
        for (var i = 0; i < nodes.length; i++) {
            flIds += nodes[i].id + ",";
        }
        $.post("/CompletionMaterials/FileList/FileRelationPost", { proId: "@(ViewBag.proId)", fId: "@(ViewBag.fId)", flIds: flIds }, dialogRefresh, "json");
        //$.pdialog.closeCurrent();
    }
    function dialogRefresh(json) {
        DWZ.ajaxDone(json);
        if (json.statusCode == DWZ.statusCode.ok) {
            $("#pagerForm", navTab.getCurrentPanel()).submit();
            $.pdialog.closeCurrent();
        }
    }
</script>
